import {getHotSongList,getHotSongTaps,reqAlbumNewSet,reqHotSinger,reqDjTopList} from "@/http/api";

export default {
    namespaced: true,//开启命名空间
    state: {
        HotSongList:[],
        HotTaps:[],
        AlbumNewSetList:[],
        newAlbum:[],
        HotSingers:[],
        DjTopList:[]
    },
    mutations: {
        GETTOPLIST(state,data){
            state.HotSongList = data.result
        },
        GETHOTTAP(state,data){
            state.HotTaps = data.tags.slice(0,5)
        },
        GETALBUMNEW(state,data){
            state.AlbumNewSetList = data.albums.slice(0,15)
        },
        GETNEW(state,data){
            state.newAlbum = data;
        },
        GETHOTSINGER(state,data){
            state.HotSingers = data.artists.slice(0,5)
        },
        GETDJTOPLIST(state,data){
            state.DjTopList = data.data.list.slice(0,5)
        },

    },
    actions: {
        async getHotSongList({commit}){
            const result = await getHotSongList()
            commit('GETTOPLIST',result.data)
        },
        async getHotSongTaps({commit}){
            const result = await getHotSongTaps()
            commit('GETHOTTAP',result.data)
        },
        async getAlbumNewSet({commit}){
            const result = await reqAlbumNewSet()
            commit('GETALBUMNEW',result.data)
        },
        async getNew({commit}){
            let result = await reqAlbumNewSet();
            if(result.status === 200){
                commit('GETNEW',result.data.albums);
            }
        },
        async getHotSinger({commit}){
            let result = await reqHotSinger();
            if(result.status === 200){
                commit('GETHOTSINGER',result.data);
            }
        },
        async getDjTopList({commit}){
            let result = await reqDjTopList();

            if(result.status === 200){
                commit('GETDJTOPLIST',result.data);
            }
        },
    },
    getters: {
    }
}
